from lxml import etree

text = \
    """
<tr class = "hots">
    <td class = "1">hot1</td>
    <td class = "2">hot2</td>
    <td class = "3">hot3</td>
    <td class = "4">hot4</td>
    <td class = "5">hot5</td>
    <td class = "6">爬虫</td>
</tr>
"""
"""
html = etree.HTML(text)
print(html)
result = etree.tostring(html, encoding='utf-8').decode('utf-8')
print(result)
# ************************************
html = etree.parse('file:///D:/Users/asus-pc/Desktop/test/test.html')
res = etree.tostring(html, encoding='utf8').decode('utf8')
print(res)
# ************************************
parser = etree.HTMLParser(encoding='utf8')
html = etree.parse('file:///D:/Users/asus-pc/Desktop/test/baidu.html', parser = parser)
res = etree.tostring(html, encoding='utf8').decode('utf8')
print(res)
"""